package com.cn.topAndFoot.service.impl;

import com.cn.common.pojo.ResultModel;
import com.cn.common.pojo.TopModel;
import com.cn.topAndFoot.mapper.TopDao;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RedisService {
    @Autowired
    private RedisTemplate<String ,Object> redisTemplate;
    @Autowired
TopDao topDao;
    public ResultModel aa(){
        List<TopModel> topModels=new ArrayList<>();

        redisTemplate.opsForValue().set("top1",topDao.top());
        return ResultModel.Data(topModels);

    }
    public ResultModel TopFromRedis(){
        List<TopModel> top = (List<TopModel>) redisTemplate.opsForValue().get("top1");
        return ResultModel.getResultModel("",0,1,top);
    }
}
